home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / misc / amag / am9311b.lha / Tips & Tricks / waitevent.asm < prev    next >
Assembly Source File  |  1992-03-03  |  3KB  |  73 lines

  1. *******************************************************************
  2. *                    Die Macros CALL und CALLI                    *
  3. *                                                                 *
  4. *******************************************************************
  5.  
  6. CALL       MACRO   
  7.              IFEQ   NARG-2
  8.                move.l   \2Base,a6   ;kann an eigene Bedürfnisse
  9.              ELSE                   ;angepaßt werden.
  10.                move.l   4.w,a6      
  11.              ENDIF
  12.              jsr   _LVO\1(a6)
  13.            ENDM   
  14.  
  15. CALLI      MACRO
  16.              jsr   _LVO\1(a6)
  17.            ENDM
  18.  
  19.  
  20. *******************************************************************
  21. * WaitEvent:  Wartet auf Ereignisse am IDCMP und gibt CODE,       *
  22. *             CLASS, MouseX, MouseY und IAddress zurück.          *
  23. *                                                                 *
  24. *******************************************************************
  25. * Eingabe:   a0    = UserPort                                     *
  26. *                                                                 *
  27. * Ausgabe:   d0    = Code                                         *
  28. *            d1    = Class                                        *
  29. *            d3/d4 = MouseX/MouseY                                *
  30. *            a1    = IAddress                                     *
  31. *******************************************************************
  32.  
  33. WaitEvent   movem.l   d2/d5-d7/a0/a2-a6,-(sp) ;Register retten
  34.  
  35.             move.l    a0,a4                   ;UPort nach a4
  36.             move.b    MP_SIGBIT(a0),d1        ;Sig. Nr. nach d1
  37.             moveq     #0,d0                   ;d0 löschen
  38.             bset      d1,d0                   ;BitNr. in d0 setzen
  39.             CALL      Wait                    ;und ab...
  40.             move.l    a4,a0                   ;UPort nach a0
  41.             CALLI     GetMsg                  ;Msg holen
  42.             move.l    d0,d5                   ;Msg retten
  43.             beq.s     .weg                    ;existiert Msg?
  44.                 
  45.             move.l    d0,a1                   ;Msg nach a1 (für ARI)
  46.             move.l    im_Class(a1),-(sp)      ;Klasse,
  47.             move      im_Code(a1),-(sp)       ;Code,
  48.             move      im_MouseX(a1),-(sp)     ;MausX,
  49.             move      im_MouseY(a1),-(sp)     ;MausY,
  50.             move.l    im_IAddress(a1),-(sp)   ;Adr in den Stapel
  51.  
  52. .loop       move.l    a4,a0                   ;UPort nach a0
  53.             CALLI     GetMsg                  ;Msg holen
  54.             tst.l     d0                      ;existiert eine?
  55.             beq.s     .weiter                 ;nö -> Weiter geht es
  56.  
  57.             move.l    d0,a1                   ;Msg nach a1
  58.             CALLI     ReplyMsg                ;Msg beantworten
  59.             bra.s     .loop                   ;--> zur Schleife
  60.  
  61. .weiter     move.l    d5,a1                   ;Msg nach a1
  62.             CALLI     ReplyMsg                ;beantworten
  63.    
  64.             move.l    (sp)+,a1                ;IAddress -> a1
  65.             move      (sp)+,d4                ;MouseY   -> d4
  66.             move      (sp)+,d3                ;MouseX   -> d3
  67.             move      (sp)+,d0                ;Code     -> d0
  68.             move.l    (sp)+,d1                ;Class    -> d1
  69.  
  70. .weg        movem.l   (sp)+,d2/d5-d7/a0/a2-a6 ;Register in Urzustand
  71.             rts                               ;...und weg!
  72.  
  73.